//Protecting the Flowers S:https://www.luogu.com.cn/problem/P2878

#include <iostream>
#include <algorithm>
using namespace std;

const int N = 1e5 + 10;

typedef long long LL;

struct Node
{
	LL t;
	LL d;
	Node()
	:t(0)
	,d(0)
	{
		
	}	
};

bool cmp(const Node& n1,const Node& n2)
{
	LL t1 = (n2.t * 2 )* n1.d;
	LL t2 = (n1.t * 2) * n2.d;
	
	return t1 > t2;
}

Node a[N];
int n;
int main()
{
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i].t >> a[i].d;
	}	
	sort(a,a+n,cmp);
	
	LL sum = 0;
	LL t = 0;
	for(int i = 0; i < n; i++)
	{
		sum += (t) * a[i].d;	
		t += a[i].t * 2;
	} 
	cout << sum;
	
	return 0;
}
